package Doan;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.PrintStream;
import java.net.Socket;

import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JSplitPane;
import javax.swing.JTextField;
import javax.swing.border.Border;
public class Client extends JPanel implements ActionListener {
	// <---------------------------------------------------------------------------------------------------------------->
	// khai bao cac bien ket noi server

	Socket sock;
	BufferedInputStream bis;
	DataInputStream in;
	PrintStream out;

	// khai bao cac bien dung toan cuc

	String nowAcc;// so tai khoan cua nguoi dang nhap
	String nowPass;// mat khau cua nguoi dang nhap
	String name; // chua ten nguoi dang nhap
	Integer tien; // chua tien nguoi dang nhap
	public static JSplitPane twoPane;

	// <----------------------------------------->
	// phan cac dieu khien cua cac panel

	// panel chon ngon ngu

	JButton tiengviet = new JButton("Vietnamese", new ImageIcon("Data/vn.png"));
	JButton english = new JButton("English", new ImageIcon("Data/english.jpg"));
	JButton disconnect = new JButton("Thoát",new ImageIcon("Data/1.png"));

	// panel login

	private JTextField txtAccountNo = new JTextField(12);
	private JPasswordField txtPassword = new JPasswordField(12);
	JLabel loggin = new JLabel("");
	JLabel account = new JLabel("");
	JLabel pin = new JLabel("");
	JLabel hd = new JLabel("");
	JButton btxoa = new JButton("");
	JButton btexit = new JButton("");
	JButton btenter = new JButton("");

	// panel chinh

	JButton RutTien = new JButton("",new ImageIcon("Data/money.png"));// Rut Tien
	JButton NapTien = new JButton("",new ImageIcon("Data/naptien.jpg"));// nap tien
	JButton SoDu = new JButton("",new ImageIcon("Data/check.jpg"));// Xem So Du
	JButton ChangePIN = new JButton("",new ImageIcon("Data/change.jpg"));// Doi PIN
	JButton ChuyenKhoan = new JButton("",new ImageIcon("Data/chuyenkhoan.jpg"));// Chuyen Khoan
	JButton KetThuc = new JButton("", new ImageIcon("Data/fn.jpg"));// Ket
																		// Thuc
	JLabel LName = new JLabel("", JLabel.CENTER);
	JLabel LSodu = new JLabel("");

	// panel rut tien

	JButton Mottram = new JButton("100.000 VND");
	
	JButton Haitram = new JButton("200.000 VND");
	JButton Namtram = new JButton("500.000 VND");
	JButton Mottrieu = new JButton("1.000.000 VND");
	JButton Sokhac = new JButton("", new ImageIcon("Data/sokhac.jpg"));// So khac
	JButton Huy = new JButton("", new ImageIcon("Data/huy.png"));// Huy giao dich rut tien
	JLabel LName2 = new JLabel("", JLabel.CENTER);

	// panel nap tien

	JButton napMottram = new JButton("100.000 VND");
	JButton napHaitram = new JButton("200.000 VND");
	JButton napNamtram = new JButton("500.000 VND");
	JButton napMottrieu = new JButton("1.000.000 VND");
	JButton napSokhac = new JButton("", new ImageIcon("Data/sokhac.jpg"));// So khac
	JButton Huynap = new JButton("", new ImageIcon("Data/huy.png"));// Huy giao dich nap tien
	JButton Returnnap = new JButton("", new ImageIcon("Data/exit.gif"));
	JLabel LName2nap = new JLabel("", JLabel.CENTER);

	// panel rut tien so khac

	JLabel LName3 = new JLabel("", JLabel.CENTER);
	JTextField txtSotien = new JTextField(20);
	JButton Rut = new JButton("",new ImageIcon("Data/thuchien.png"));// Rut
	JButton Huy2 = new JButton("",new ImageIcon("Data/1.png"));// Huy giao dich rut tien so khac
	JLabel dieukien = new JLabel("");
	JLabel tbruttien = new JLabel("");

	// panel nap tien so khac

	JLabel LName3nap = new JLabel("", JLabel.CENTER);
	JTextField txtSotiennap = new JTextField(20);
	JButton Nap = new JButton("",new ImageIcon("Data/thuchien.png"));// Rut
	JButton Huy2nap = new JButton("",new ImageIcon("Data/1.png"));// Huy giao dich nap tien so khac
	JLabel dieukiennap = new JLabel("");
	JLabel tbnaptien = new JLabel("");

	// panel Chuyen Khoan

	JTextField Sotkhoan = new JTextField(12);
	JTextField Stien = new JTextField(12);
	JButton Thuchien = new JButton("",new ImageIcon("Data/thuchien.png"));// Thuc hien
	JButton Huy1 = new JButton("",new ImageIcon("Data/1.png"));// Huy giao dich
	JLabel label = new JLabel("");
	JLabel tknhan = new JLabel("");
	JLabel sotien = new JLabel("");

	// panel thong bao rut tien

	JLabel l1 = new JLabel("", JLabel.RIGHT);
	JLabel l2 = new JLabel("", JLabel.RIGHT);
	JLabel l3 = new JLabel("", JLabel.RIGHT);
	JLabel l4 = new JLabel("", JLabel.RIGHT);
	JLabel thongbao = new JLabel("");
	JLabel taikhoan = new JLabel("");
	JLabel strut = new JLabel("");
	JLabel sdutte = new JLabel("");
	JLabel sduchophep = new JLabel("");
	JLabel Hoi = new JLabel("");
	JButton Co = new JButton("");
	JButton Khong = new JButton("");

	// panel thong bao nap tien

	JLabel l1nap = new JLabel("", JLabel.RIGHT);
	JLabel l2nap = new JLabel("", JLabel.RIGHT);
	JLabel l3nap = new JLabel("", JLabel.RIGHT);
	JLabel l4nap = new JLabel("", JLabel.RIGHT);
	JLabel thongbaonap = new JLabel("");
	JLabel taikhoannap = new JLabel("");
	JLabel stnap = new JLabel("");
	JLabel sduttenap = new JLabel("");
	JLabel sduchophepnap = new JLabel("");
	JLabel Hoinap = new JLabel("");
	JButton Conap = new JButton("");
	JButton Khongnap = new JButton("");

	// panel thong bao chuyen khoan

	JLabel l5 = new JLabel("", JLabel.RIGHT);
	JLabel l6 = new JLabel("", JLabel.RIGHT);
	JLabel l7 = new JLabel("", JLabel.RIGHT);
	JLabel l8 = new JLabel("", JLabel.RIGHT);
	JLabel l9 = new JLabel("", JLabel.RIGHT);
	JLabel thongbao1 = new JLabel("");
	JLabel taikhoan2 = new JLabel("");
	JLabel taikhoan1 = new JLabel("");
	JLabel strut1 = new JLabel("");
	JLabel sdutte1 = new JLabel("");
	JLabel sduchophep1 = new JLabel("");
	JLabel Hoi1 = new JLabel("");
	JButton Co1 = new JButton("");
	JButton Khong1 = new JButton("");

	// panel change PIN

	JPasswordField curPin = new JPasswordField(20);
	JPasswordField NewPin = new JPasswordField(20);
	JPasswordField confirmPin = new JPasswordField(20);
	JButton ChangeP = new JButton("", new ImageIcon("Data/4.jpg"));// Change
	JButton Quaylai = new JButton("", new ImageIcon("Data/quaylai1.png"));// Quay
																		// lai
	JLabel tbdoipin = new JLabel("");
	JLabel pincu = new JLabel("");
	JLabel pinmoi = new JLabel("");
	JLabel xacnhan = new JLabel("");

	// cac loi va cac thong bao

	String loi1, loi2, loi3, loi4, loi5, loi6, loi7, loi8, loi14, loi22, loi25,
			loi23, loi0, thoat;
	String stconlai;

	// <--------------------------->
	// tao cac panel

	JPanel Plog = login();
	JPanel Pmain = Chinh();
	JPanel PRut = Rut();
	JPanel pnap = Nap();
	JPanel PThongbao = ThongBao();
	JPanel PThongbao1 = ThongBao1();
	JPanel pThongbaonap = ThongBaoNap();
	JPanel PSokhac = SoKhac();
	JPanel pSokhacnap = SoKhacNap();
	JPanel Ppin = doipin();
	JPanel PChuyenkhoan = Chuyenkhoan();

	// <------------------------------------------------------------------------------------------------------------->
	// <------------------------------------------------------------------------------------------------------------->
	// phan cac ham tao panel
	// panel lua chon ngon ngu

	public JPanel chonngonngu() {
		JPanel Head = new JPanel();
		Label l=new Label("Language:");
		l.setFont(new Font("Courier New", Font.BOLD,16));
		 l.setForeground(Color.BLACK);
		JPanel Body = new JPanel();
		Body.setLayout(new FlowLayout());
		
		Body.setBorder(BorderFactory.createEmptyBorder(50, 5, 50, 15));
		Body.add(l);
		Body.add(tiengviet);
		tiengviet.addActionListener(this);
		tiengviet.setLocation(400, 100);
		Body.add(english);
		english.addActionListener(this);
		Head.add(disconnect);
		disconnect.addActionListener(this);
		JPanel ngonngu = new JPanel(new BorderLayout());
		ngonngu.setBackground(SystemColor.controlHighlight);
		ngonngu.add(Head, BorderLayout.NORTH);
		ngonngu.add(Body, BorderLayout.CENTER);
		return ngonngu;
	}

	// panel login

	public JPanel login() {
		JPanel logHead = new JPanel();
		logHead.setLayout(new GridLayout(2, 1));
		logHead.setBorder(BorderFactory.createEmptyBorder(5, 200, 7, 150));
		logHead.add(loggin);
		loggin.setFont(new Font("Courie", Font.BOLD, 30));
		logHead.add(hd);
		hd.setFont(new Font("Courie", Font.ITALIC, 15));

		JPanel logBody = new JPanel();
		logBody.setLayout(new GridLayout(2, 2, 10, 20));
		logBody.setBorder(BorderFactory.createEmptyBorder(30, 200, 50, 200));
		logBody.add(account);// ,JLabel.RIGHT
		account.setFont(new Font("Courie", Font.BOLD, 15));
		logBody.add(txtAccountNo);
		logBody.add(pin);// ,JLabel.RIGHT
		pin.setFont(new Font("Courie", Font.BOLD, 15));
		logBody.add(txtPassword);

		// Tao ban phim
		JPanel logFoot = new JPanel(); // tao lay out ban phim
		logFoot.setLayout(new GridLayout(1, 3, 3, 3));
		logFoot.setBorder(BorderFactory.createEmptyBorder(2, 100, 20, 100)); // canh
																				// le
																				// tren,
																				// trai,
																				// duoi,
																				// phai
																				// cho
																				// ban
																				// phim
		logFoot.add(btxoa);
		btxoa.addActionListener(this);
		btxoa.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				txtPassword.setText(null);
			}
		});

		logFoot.add(btexit);
		btexit.addActionListener(this);
		btexit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		logFoot.add(btenter);
		btenter.addActionListener(this);
		JPanel log = new JPanel(new BorderLayout());
		log.setBackground(SystemColor.controlHighlight);
		log.add(logHead, BorderLayout.NORTH);
		log.add(logBody, BorderLayout.CENTER);
		log.add(logFoot, BorderLayout.SOUTH);
		return log;
	}

	// panel chinh

	public JPanel Chinh() {
		JPanel left = new JPanel(new GridLayout(3, 1, 5, 10));
		left.setBorder(BorderFactory.createEmptyBorder(50, 5, 50, 15));
		left.add(RutTien);
		RutTien.addActionListener(this);
		left.add(SoDu);
		SoDu.addActionListener(this);
		left.add(ChangePIN);
		ChangePIN.addActionListener(this);
		left.setBackground(SystemColor.controlHighlight);
		JPanel right = new JPanel(new GridLayout(3, 1, 5, 10));
		right.setBorder(BorderFactory.createEmptyBorder(50, 5, 50, 15));
		right.add(ChuyenKhoan);
		ChuyenKhoan.addActionListener(this);
		right.add(NapTien);
		NapTien.addActionListener(this);
		right.add(KetThuc);
		KetThuc.addActionListener(this);
		right.setBackground(SystemColor.controlHighlight);
		JPanel head = new JPanel();
		head.add(LName);
		LName.setFont(new Font("Courie", Font.ITALIC, 20));
		head.setBackground(SystemColor.controlHighlight);
		JPanel foot = new JPanel();
		JPanel main = new JPanel(new BorderLayout());
		main.add(head, "North");
		main.add(left, "West");
		main.add(right, "East");
		main.add(foot, "South");
		main.add(LSodu);
		main.setBackground(SystemColor.controlHighlight);
		return main;
	}

	// panel doi pin

	public JPanel doipin() {
		JPanel Head = new JPanel();
		Head.add(tbdoipin);
		Head.setBackground(SystemColor.controlHighlight);
		tbdoipin.setFont(new Font("Courie", Font.BOLD, 20));
		JPanel p1 = new JPanel(new GridLayout(3, 3, 3, 3));
		p1.setBorder(BorderFactory.createEmptyBorder(50, 5, 50, 15));
		p1.add(pincu);// ,JLabel.RIGHT
		p1.add(curPin);
		p1.add(pinmoi);
		p1.add(NewPin);
		p1.add(xacnhan);
		p1.add(confirmPin);

		JPanel p2 = new JPanel();
		p2.add(ChangeP);
		p2.add(Quaylai);
		Quaylai.addActionListener(this);
		ChangeP.addActionListener(this);

		JPanel p = new JPanel(new BorderLayout());
		p1.setBackground(SystemColor.controlHighlight);
		p.add(p2, "South");
		p.add(Head, "North");
		p.add(p1);
		p2.setBackground(SystemColor.controlHighlight);
		p.setBackground(SystemColor.controlHighlight);
		return p;

	}

	// panel rut tien

	public JPanel Rut() {
		JPanel left = new JPanel(new GridLayout(3, 1, 5, 10));
		left.setBorder(BorderFactory.createEmptyBorder(50, 5, 50, 15));
		left.add(Mottram);
		Mottram.addActionListener(this);
		left.add(Haitram);
		Haitram.addActionListener(this);
		left.add(Namtram);
		Namtram.addActionListener(this);
		left.setBackground(SystemColor.controlHighlight);
		JPanel right = new JPanel(new GridLayout(3, 1, 5, 10));
		right.setBorder(BorderFactory.createEmptyBorder(50, 5, 50, 15));
		right.add(Mottrieu);
		Mottrieu.addActionListener(this);
		right.add(Sokhac);
		Sokhac.addActionListener(this);
		right.add(Huy);
		Huy.addActionListener(this);
		right.setBackground(SystemColor.controlHighlight);
		JPanel head = new JPanel();
		head.add(LName2);
		LName2.setFont(new Font("Courie", Font.ITALIC, 20));
		head.setBackground(SystemColor.controlHighlight);
		JPanel foot = new JPanel();
		JPanel m = new JPanel(new BorderLayout());
		m.add(head, "North");
		m.add(left, "West");
		m.add(right, "East");
		m.add(foot, "South");
		m.setBackground(SystemColor.controlHighlight);
		return m;
	}

	// panel nap tien

	public JPanel Nap() {
		JPanel left = new JPanel(new GridLayout(3, 1, 5, 10));
		left.setBorder(BorderFactory.createEmptyBorder(50, 5, 50, 15));
		left.add(napMottram);
		napMottram.addActionListener(this);
		left.add(napHaitram);
		napHaitram.addActionListener(this);
		left.add(napNamtram);
		napNamtram.addActionListener(this);
		left.setBackground(SystemColor.controlHighlight);
		JPanel right = new JPanel(new GridLayout(3, 1, 5, 10));
		right.setBorder(BorderFactory.createEmptyBorder(50, 5, 50, 15));
		right.add(napMottrieu);
		napMottrieu.addActionListener(this);
		right.add(napSokhac);
		napSokhac.addActionListener(this);
		right.add(Huynap);
		Huynap.addActionListener(this);
		right.setBackground(SystemColor.controlHighlight);
		JPanel head = new JPanel();
		head.add(LName2nap);
		LName2nap.setFont(new Font("Courie", Font.ITALIC, 20));
		head.setBackground(SystemColor.controlHighlight);
		JPanel foot = new JPanel();
		JPanel mai = new JPanel(new BorderLayout());
		mai.add(head, "North");
		mai.add(left, "West");
		mai.add(right, "East");
		mai.add(foot, "South");
		mai.setBackground(SystemColor.controlHighlight);
		return mai;
	}

	// panel rut tien so khac

	public JPanel SoKhac() {
		JPanel head = new JPanel(new GridLayout(2, 1, 5, 10));
		LName3.setFont(new Font("Courie", Font.ITALIC, 20));
		head.add(LName3);
		head.add(dieukien);
		head.setBackground(SystemColor.controlHighlight);
		JPanel left = new JPanel();
		left.add(tbruttien);
		left.add(txtSotien);
		left.setBorder(BorderFactory.createEmptyBorder(30, 5, 50, 15));
		left.setBackground(SystemColor.controlHighlight);
		JPanel foot = new JPanel();
		foot.add(Rut);
		Rut.addActionListener(this);
		foot.add(Huy2);
		Huy2.addActionListener(this);
		foot.setBorder(BorderFactory.createEmptyBorder(30, 5, 50, 15));
		foot.setBackground(SystemColor.controlHighlight);
		JPanel main = new JPanel(new BorderLayout());
		main.add(head, "North");
		main.add(left, "West");
		main.add(foot, "South");
		main.setBackground(SystemColor.controlHighlight);
		return main;
	}

	// panel nap tien so khac

	public JPanel SoKhacNap() {
		JPanel head = new JPanel(new GridLayout(2, 1, 5, 10));
		LName3nap.setFont(new Font("Courie", Font.ITALIC, 20));
		head.add(LName3nap);
		head.add(dieukiennap);
		head.setBackground(SystemColor.controlHighlight);
		JPanel left = new JPanel();
		left.add(tbnaptien);
		left.add(txtSotiennap);
		left.setBorder(BorderFactory.createEmptyBorder(30, 5, 50, 15));
		left.setBackground(SystemColor.controlHighlight);
		JPanel foot = new JPanel();
		foot.add(Nap);
		Nap.addActionListener(this);
		foot.add(Huy2nap);
		Huy2nap.addActionListener(this);
		foot.setBorder(BorderFactory.createEmptyBorder(30, 5, 50, 15));
		foot.setBackground(SystemColor.controlHighlight);
		JPanel main = new JPanel(new BorderLayout());
		main.add(head, "North");
		main.add(left, "West");
		main.add(foot, "South");
		main.setBackground(SystemColor.controlHighlight);
		return main;
	}

	// panel thong bao sau khi rut tien

	public JPanel ThongBao() {
		JPanel p1 = new JPanel();
		p1.add(thongbao);
		thongbao.setFont(new Font("Courie", Font.ITALIC, 20));
		p1.setBackground(SystemColor.controlHighlight);
		JPanel p2 = new JPanel(new GridLayout(5, 2, 5, 10));
		p2.add(strut);// ,JLabel.RIGHT
		p2.add(l2);
		p2.add(sdutte);// ,JLabel.RIGHT
		p2.add(l3);
		p2.add(sduchophep);// ,JLabel.RIGHT
		p2.add(l4);
		p2.setBackground(SystemColor.controlHighlight);
		JPanel p3 = new JPanel(new GridLayout(2, 1, 5, 10));
		p3.add(Hoi, JLabel.CENTER);
		p3.setBackground(SystemColor.controlHighlight);
		JPanel p4 = new JPanel();
		p4.add(Co);
		Co.addActionListener(this);
		p4.add(Khong);
		Khong.addActionListener(this);
		p3.add(p4);
		p4.setBackground(SystemColor.controlHighlight);
		JPanel p5 = new JPanel();
		p5.setBackground(SystemColor.controlHighlight);
		JPanel main = new JPanel(new BorderLayout());
		Dimension d = new Dimension(50, 50);
		p2.setMaximumSize(d);
		main.add(p1, "North");
		main.add(p5, "East");
		main.add(p3, "South");
		main.add(p2, "Center");
		main.setBackground(SystemColor.controlHighlight);
		return (main);
	}

	// panel thong bao sau khi nop tien

	public JPanel ThongBaoNap() {
		JPanel p11 = new JPanel();
		p11.add(thongbaonap);
		p11.setBackground(SystemColor.controlHighlight);
		thongbaonap.setFont(new Font("Courie", Font.ITALIC, 20));
		JPanel p22 = new JPanel(new GridLayout(5, 2, 5, 10));
		p22.add(stnap);// ,JLabel.RIGHT
		p22.add(l2nap);
		p22.add(sduttenap);// ,JLabel.RIGHT
		p22.add(l3nap);
		p22.add(sduchophepnap);// ,JLabel.RIGHT
		p22.add(l4nap);
		p22.setBackground(SystemColor.controlHighlight);
		JPanel p32 = new JPanel(new GridLayout(2, 1, 5, 10));
		p32.add(Hoinap, JLabel.CENTER);
		p32.setBackground(SystemColor.controlHighlight);
		JPanel p42 = new JPanel();
		p42.add(Conap);
		Conap.addActionListener(this);
		p42.add(Khongnap);
		p42.setBackground(SystemColor.controlHighlight);
		Khongnap.addActionListener(this);
		p32.add(p42);
		JPanel p52 = new JPanel();
		JPanel main = new JPanel(new BorderLayout());
		Dimension d = new Dimension(50, 50);// tao ra doi tuong de thay doi kich
											// thuot cua component
		p22.setMaximumSize(d);
		main.add(p11, "North");
		main.add(p52, "East");
		main.add(p32, "South");
		main.add(p22, "Center");
		main.setBackground(SystemColor.controlHighlight);
		return (main);
	}

	// panel chuyen khoan

	public JPanel Chuyenkhoan() {
		JPanel head = new JPanel();
		head.add(label, JLabel.CENTER);
		head.setBackground(SystemColor.controlHighlight);
		label.setFont(new Font("Courie", Font.BOLD, 20));
		JPanel body = new JPanel(new GridLayout(3, 3, 5, 5));
		body.setBorder(BorderFactory.createEmptyBorder(70, 5, 70, 15));
		body.add(tknhan);
		body.add(Sotkhoan);
		body.add(sotien);
		body.add(Stien);
		body.setBackground(SystemColor.controlHighlight);
		JPanel foot = new JPanel();
		foot.add(Thuchien);
		Thuchien.addActionListener(this);
		foot.add(Huy1);
		Huy1.addActionListener(this);
		foot.setBackground(SystemColor.controlHighlight);
		JPanel ck = new JPanel(new BorderLayout());
		ck.add(head, "North");
		ck.add(foot, "South");
		ck.add(body, "Center");
		ck.setBackground(SystemColor.controlHighlight);
		return ck;

	}

	// panel thong bao sau khi chuyen khoan

	public JPanel ThongBao1() {
		JPanel p1 = new JPanel();
		p1.add(thongbao1);
		thongbao1.setFont(new Font("Courie", Font.ITALIC, 20));
		p1.setBackground(SystemColor.controlHighlight);
		JPanel p2 = new JPanel(new GridLayout(5, 2, 5, 10));
		p2.add(taikhoan1, JLabel.CENTER);// ,JLabel.RIGHT
		p2.add(l5);
		p2.add(taikhoan2);
		p2.add(l6);
		p2.add(strut1);
		p2.add(l7);
		p2.add(sdutte1);
		p2.add(l8);
		p2.add(sduchophep1);
		p2.add(l9);
		p2.setBackground(SystemColor.controlHighlight);
		JPanel p3 = new JPanel(new GridLayout(2, 1, 5, 10));
		p3.add(Hoi1, JLabel.CENTER);
		JPanel p4 = new JPanel();
		p4.add(Co1);
		Co1.addActionListener(this);
		p4.add(Khong1);
		Khong1.addActionListener(this);
		p3.add(p4);
		JPanel main = new JPanel(new BorderLayout());
		Dimension d = new Dimension(50, 50);
		p2.setMaximumSize(d);
		main.add(p1, "North");
		main.add(p3, "South");
		main.add(p2, "Center");
		main.setBackground(SystemColor.controlHighlight);
		p3.setBackground(SystemColor.controlHighlight);
		p4.setBackground(SystemColor.controlHighlight);
		return (main);
	}

	// <------------------------------------------------------------------------------------>
	public Client() {
		connect();
		add(chonngonngu());

	}

	private static JPanel createLogoPane() {
		JPanel logoPane = new JPanel(new BorderLayout());
		logoPane.setBackground(new Color(255, 255, 255));
		logoPane.add(new JLabel(new ImageIcon("Data/donga.png")));
		return logoPane;
	}

	// <---------------------------------------------------------------------------------->
	// ket thuc phan tao panel
	// <---------------------------------------------------------------------------------
	// <-------------------------------------------------------------------------------------------------->
	// cac ham dung trong chuong trinh
	// ham ket noi voi may chu

	public void connect() {
		try {
			//tao socket yeu cau ket noi voi may chu o cong 8000 voi ten localhost
			sock = new Socket("localhost", 8000);// set IP
			System.out.println("Client:Da ket noi...");
			System.out.println("Client:" + sock);
			bis = new BufferedInputStream(sock.getInputStream()); 
			in = new DataInputStream(bis);
			out = new PrintStream(sock.getOutputStream()); //tao luong nhap de goi den server
		} catch (Exception e) {

			System.out.println("Client:Loi ket noi" + e);
		}

	}

	// ham them dau cham vao String tien

	public String ThanhTien(String sotien) {
		int leng = sotien.length();
		char mang[];
		mang = sotien.toCharArray();// chuyen chuoi thanh 1 mang ky tu
		if (leng == 4)
			return mang[0] + "." + mang[1] + "" + mang[2] + "" + mang[3]; // 1.000
		if (leng == 5)
			return mang[0] + "" + mang[1] + "." + mang[2] + "" + mang[3] + ""
					+ mang[4];// 10.000
		if (leng == 6)
			return mang[0] + "" + mang[1] + "" + mang[2] + "." + mang[3] + ""
					+ mang[4] + "" + mang[5]; // 100.000
		if (leng == 7)
			return mang[0] + "." + mang[1] + "" + mang[2] + "" + mang[3] + "."
					+ mang[4] + "" + mang[5] + "" + mang[6]; // 1.000.000
		if (leng == 8)
			return mang[0] + "" + mang[1] + "." + mang[2] + "" + mang[3] + ""
					+ mang[4] + "." + mang[5] + "" + mang[6] + "" + mang[7]; // 10.000.000
		if (leng == 9)
			return mang[0] + "" + mang[1] + "" + mang[2] + "." + mang[3] + ""
					+ mang[4] + "" + mang[5] + "." + mang[6] + "" + mang[7]
					+ "" + mang[8]; // 100.000.000
		if (leng == 10)
			return mang[0] + "." + mang[1] + "" + mang[2] + "" + mang[3] + "."
					+ mang[4] + "" + mang[5] + "" + mang[6] + "." + mang[7]
					+ "" + mang[8] + "" + mang[9];// 1.000.000.000
		if (leng == 11)
			return mang[0] + "" + mang[1] + "." + mang[2] + "" + mang[3] + ""
					+ mang[4] + "." + mang[5] + "" + mang[6] + "" + mang[7]
					+ "." + mang[8] + "" + mang[9] + "" + mang[10]; // 10.000.000.000
		if (leng == 12)
			return mang[0] + "" + mang[1] + "" + mang[2] + "." + mang[3] + ""
					+ mang[4] + "" + mang[5] + "." + mang[6] + "" + mang[7]
					+ "" + mang[8] + "." + mang[9] + "" + mang[10] + ""
					+ mang[11]; // 100.000.000.000
		if (leng == 13)
			return mang[0] + "." + mang[1] + "" + mang[2] + "" + mang[3] + "."
					+ mang[4] + "" + mang[5] + "" + mang[6] + "." + mang[7]
					+ "" + mang[8] + "" + mang[9] + "." + mang[10] + ""
					+ mang[11] + "" + mang[12]; // 1.000.000.000.000
		if (leng == 14)
			return mang[0] + "" + mang[1] + "." + mang[2] + "" + mang[3] + ""
					+ mang[4] + "." + mang[5] + "" + mang[6] + "" + mang[7]
					+ "." + mang[8] + "" + mang[9] + "" + mang[10] + "."
					+ mang[11] + "" + mang[12] + "" + mang[13]; // 10.000.000.000.000
		if (leng == 15)
			return mang[0] + "" + mang[1] + "" + mang[2] + "." + mang[3] + ""
					+ mang[4] + "" + mang[5] + "." + mang[6] + "" + mang[7]
					+ "" + mang[8] + "." + mang[9] + "" + mang[10] + ""
					+ mang[11] + "." + mang[12] + "" + mang[13] + "" + mang[14];// 100.000.000.000.000
		if (leng == 16)
			return mang[0] + "." + mang[1] + "" + mang[2] + "" + mang[3] + "."
					+ mang[4] + "" + mang[5] + "" + mang[6] + "." + mang[7]
					+ "" + mang[8] + "" + mang[9] + "." + mang[10] + ""
					+ mang[11] + "" + mang[12] + "." + mang[13] + "" + mang[14]
					+ "" + mang[15];// 1.000.000.000.000.000
		if (leng == 17)
			return mang[0] + "" + mang[1] + "." + mang[2] + "" + mang[3] + ""
					+ mang[4] + "." + mang[5] + "" + mang[6] + "" + mang[7]
					+ "." + mang[8] + "" + mang[9] + "" + mang[10] + "."
					+ mang[11] + "" + mang[12] + "" + mang[13] + "." + mang[14]
					+ "" + mang[15] + "" + mang[16]; // 10.000.000.000.000
		if (leng == 18)
			return mang[0] + "" + mang[1] + "" + mang[2] + "." + mang[3] + ""
					+ mang[4] + "" + mang[5] + "." + mang[6] + "" + mang[7]
					+ "" + mang[8] + "." + mang[9] + "" + mang[10] + ""
					+ mang[11] + "." + mang[12] + "" + mang[13] + "" + mang[14]
					+ "." + mang[15] + "" + mang[16] + "" + mang[17]; // 100.000.000.000.000
		else
			return sotien;
	}

	// cac ham xu ly va nhan ket qua tu server
	public int Dangnhap(String loaigiaodich, String stk, String mk,
			String bienrong) throws Exception {
		int ketqua = 0;
		out.println(loaigiaodich);
		out.flush();
		out.println(stk);
		out.flush();
		out.println(mk);
		out.flush();
		out.println(bienrong);
		out.flush();
		String kq = in.readLine();
		ketqua = Integer.parseInt(kq);
		name = in.readLine();
		System.out.println("Ten cua nguoi dang nhap nhan duoc tu server la:"
				+ name);
		return ketqua;
	}

	public void Xemsodu(String loaigiaodich, String stk, String bienrong1,
			String bienrong2) throws Exception {
		out.println(loaigiaodich);
		out.flush();
		out.println(stk);
		out.flush();
		out.println(bienrong1);
		out.flush();
		out.println(bienrong2);
		out.flush();
		String kq = in.readLine();
		tien = Integer.parseInt(kq);
		System.out.println("So tien nhan duoc tu server la:" + tien);
		LSodu.setText(stconlai + ThanhTien(tien.toString()) + " VND");

	}

	public int Nap(String loaigiaodich, String stk, Integer sotien,
			String bienrong) throws Exception {
		int ketqua = 0;
		out.println(loaigiaodich);
		out.flush();
		out.println(stk);
		out.flush();
		out.println(sotien);
		out.flush();
		out.println(bienrong);
		out.flush();
		String kq = in.readLine();
		ketqua = Integer.parseInt(kq);
		String t = in.readLine();
		tien = Integer.parseInt(t);
		if (ketqua == 1) {
			l1nap.setText(txtAccountNo.getText());// so tai khoan
			l2nap.setText(ThanhTien(sotien.toString()) + " VND");// so tien nap
			l3nap.setText(ThanhTien(tien.toString()) + " VND");// tong so tien
																// trong tai
																// khoan
			Integer tam = tien - 50000;
			l4nap.setText(ThanhTien(tam.toString()) + " VND");// so tien cho
																// phep duoc rut

		}
		return ketqua;

	}

	public int Rut(String loaigiaodich, String stk, Integer sotien,
			String bienrong) throws Exception {
		int ketqua = 0;
		out.println(loaigiaodich);
		out.flush();
		out.println(stk);
		out.flush();
		out.println(sotien);
		out.flush();
		out.println(bienrong);
		out.flush();
		String kq = in.readLine();
		ketqua = Integer.parseInt(kq);
		String tienserver = in.readLine();
		tien = Integer.parseInt(tienserver);
		if (ketqua == 1) {
			l1.setText(txtAccountNo.getText());// so tai khoan
			l2.setText(ThanhTien(sotien.toString()) + " VND");// so tien rut
			l3.setText(ThanhTien(tien.toString()) + " VND");// so tien con lai
															// trong tai khoan
			Integer tam = tien - 50000;
			l4.setText(ThanhTien(tam.toString()) + " VND");// so tien duoc phep
															// rut tiep

		}
		return ketqua;
	}

	public int Doimatkhau(String loaigiaodich, String stk, String mkmoi,
			String bienrong) throws Exception {
		int ketqua = 0;
		out.println(loaigiaodich);
		out.flush();
		out.println(stk);
		out.flush();
		out.println(mkmoi);
		out.flush();
		out.println(bienrong);
		out.flush();
		String kq = in.readLine();
		ketqua = Integer.parseInt(kq);
		return ketqua;
	}

	public int Chuyenkhoan(String loaigiaodich, String tkgui, String tknhan,
			Integer sotien) throws Exception {
		int ketqua = 0;
		out.println(loaigiaodich);
		out.flush();
		out.println(tkgui);
		out.flush();
		out.println(tknhan);
		out.flush();
		out.println(sotien);
		out.flush();
		String kq = in.readLine();
		ketqua = Integer.parseInt(kq);
		String t = in.readLine();
		tien = Integer.parseInt(t);
		if (ketqua == 1) {
			l5.setText(tkgui);// so tai khoan nguoi chuyen
			l6.setText(Sotkhoan.getText());// so tai khoan nguoi duoc chuyen
			l7.setText(ThanhTien(sotien.toString()) + " VND");// so tien chuyen
			l8.setText(ThanhTien(Long.toString(tien)) + " VND");// so tien con
																// trong tai
																// khoan
			Integer tam = tien - 50000;
			l9.setText(ThanhTien(Integer.toString(tam)) + " VND");// so du cho
																	// phep
		}

		return ketqua;

	}

	public int Kiemtratknhan(String loaigiaodich, String stk, String bienrong1,
			String bienrong2) throws Exception {
		int ketqua = 0;
		out.println(loaigiaodich);
		out.flush();
		out.println(stk);
		out.flush();
		out.println(bienrong1);
		out.flush();
		out.println(bienrong2);
		out.flush();
		String kq = in.readLine();
		ketqua = Integer.parseInt(kq);
		return ketqua;

	}

	// <-------------------------------------------------------------------------->
	// ket thuc cac ham
	// <---------------------------------------------------------------------------------------------------->

	// <----------------------------------------------------------------------------------------------------->
	// PHAN XU LY SU KIEN
	// <----------------------------------------------------------------------------------------------------->

	public void actionPerformed(ActionEvent ae) {

		// <------------------------------------------------------------------------------------------------------->
		// login

		if (ae.getSource() == btxoa) {
			txtAccountNo.setText("");
			txtPassword.setText("");
			txtAccountNo.requestFocus();

		}

		else if (ae.getSource() == btenter)

		{
			try {
				String tendangnhap = txtAccountNo.getText();
				String mk = txtPassword.getText();
				int thanhcong = Dangnhap("DangNhap", tendangnhap, mk, "null");
				if (thanhcong == 0) {
					JOptionPane.showMessageDialog(this, loi1, "Thong bao",
							JOptionPane.ERROR_MESSAGE);// tai khoan hoac mat
														// khau khong hop le
					txtAccountNo.setText("");
					txtPassword.setText("");
					txtAccountNo.requestFocus();

				}

				else {
					nowAcc = txtAccountNo.getText();
					nowPass = txtPassword.getText();
					LName.setText(" WELCOME " + name.toUpperCase());
				   LName.setFont(new Font("Courier New", Font.BOLD,25));
				   LName.setForeground(Color.red);
					LName2.setText(" WELCOME " + name.toUpperCase());
					LName2.setFont(new Font("Courier New", Font.BOLD,25));
					   LName2.setForeground(Color.red);
					LName3.setText(" WELCOME " + name.toUpperCase());
					LName3.setFont(new Font("Courier New", Font.BOLD,25));
					   LName3.setForeground(Color.red);
					LName2nap.setText(" WELCOME " + name.toUpperCase());
					LName2nap.setFont(new Font("Courier New", Font.BOLD,25));
					   LName2nap.setForeground(Color.red);
					LName3nap.setText(" WELCOME " + name.toUpperCase());
					LName3nap.setFont(new Font("Courier New", Font.BOLD,25));
					   LName3nap.setForeground(Color.red);
					twoPane.setBottomComponent(Pmain);
				}

			} catch (Exception e) {
				System.out.println("loi gi day" + e);
			}

		}
		// <-------------------------------------------------------------------------------------------------->

		// DOI MAT KHAU

		else if (ae.getSource() == ChangePIN) {
			LSodu.setText("");
			twoPane.setBottomComponent(Ppin);
			curPin.setText("");
			NewPin.setText("");
			confirmPin.setText("");
		}

		else if (ae.getSource() == ChangeP) {
			if (curPin.getText().equals(nowPass)) {
				String pass = new String();
				pass = NewPin.getText();
				if (pass != "") {
					if (pass.equals(confirmPin.getText())) {

						if (pass.length() <= 20) {

							try {

								int thanhcong = Doimatkhau("DoiMatKhau",
										nowAcc, pass, "null");

								if (thanhcong == 1) {
									nowPass = pass;
									curPin.setText("");
									NewPin.setText("");
									confirmPin.setText("");
								}

							} catch (Exception ee) {

								System.out.println(ee);

							}

							JOptionPane.showMessageDialog(this, loi2, loi0,
									JOptionPane.INFORMATION_MESSAGE);// Doi mat
																		// khau
																		// thanh
																		// cong
							twoPane.setBottomComponent(Pmain);
						}

						else {
							JOptionPane.showMessageDialog(this, loi22, loi0,
									JOptionPane.ERROR_MESSAGE);// mat khau khong
																// duoc dai qua
																// 20 ki tu
							NewPin.setText("");
							confirmPin.setText("");
							NewPin.requestFocus();
						}

					} else {
						JOptionPane.showMessageDialog(this, loi3, loi0,
								JOptionPane.ERROR_MESSAGE);// sai confirm
						confirmPin.setText("");
						confirmPin.requestFocus();
					}

				} else {
					JOptionPane.showMessageDialog(this, loi23, loi0,
							JOptionPane.ERROR_MESSAGE);// mat khau moi khong
														// duoc de trong
					NewPin.requestFocus();
				}

			} else {
				JOptionPane.showMessageDialog(this, loi4, loi0,
						JOptionPane.ERROR_MESSAGE);// sai pass mat khau
				curPin.setText("");
				curPin.requestFocus();
			}

		} else if (ae.getSource() == Quaylai) {
			twoPane.setBottomComponent(Pmain);
		}

		// <------------------------------------------------------------------------------------>
		// RUT TIEN
		// <------------------------------------------------------------------------------------>

		else if (ae.getSource() == RutTien) {
			twoPane.setBottomComponent(PRut);
			LSodu.setText("");
		} else if (ae.getSource() == Mottram) {
			try {
				int thanhcong = Rut("RutTien", nowAcc, 100000, "null");

				if (thanhcong == 1)
					twoPane.setBottomComponent(PThongbao);
				else
					JOptionPane.showMessageDialog(this, loi5, loi0,
							JOptionPane.ERROR_MESSAGE);// khong du tien
			} catch (Exception e) {
				System.out.println(e);
			}

		}

		else if (ae.getSource() == Haitram) {
			try {
				int thanhcong = Rut("RutTien", nowAcc, 200000, "null");
				if (thanhcong == 1)
					twoPane.setBottomComponent(PThongbao);
				else
					JOptionPane.showMessageDialog(this, loi5, loi0,
							JOptionPane.ERROR_MESSAGE);// khong du tien

			} catch (Exception e) {
				System.out.println(e);
			}

		} else if (ae.getSource() == Namtram) {

			try {
				int thanhcong = Rut("RutTien", nowAcc, 500000, "null");
				if (thanhcong == 1)
					twoPane.setBottomComponent(PThongbao);
				else
					JOptionPane.showMessageDialog(this, loi5, loi0,
							JOptionPane.ERROR_MESSAGE);// khong du tien

			} catch (Exception e) {
				System.out.println(e);
			}

		} else if (ae.getSource() == Mottrieu) {

			try {
				int thanhcong = Rut("RutTien", nowAcc, 1000000, "null");
				if (thanhcong == 1)
					twoPane.setBottomComponent(PThongbao);
				else
					JOptionPane.showMessageDialog(this, loi5, loi0,
							JOptionPane.ERROR_MESSAGE);// khong du tien

			} catch (Exception e) {
				System.out.println(e);
			}

		} else if (ae.getSource() == Sokhac) {
			twoPane.setBottomComponent(PSokhac);
		} else if (ae.getSource() == Rut) {
			try {
				int tiennhap = Integer.valueOf(txtSotien.getText(), 10);
				if ((tiennhap % 50000 == 0) && (tiennhap != 0)) {

					try {
						int thanhcong = Rut("RutTien", nowAcc, tiennhap, "null");
						if (thanhcong == 1) {
							txtSotien.setText("");
							twoPane.setBottomComponent(PThongbao);
						} else {

							JOptionPane.showMessageDialog(this, loi5, loi0,
									JOptionPane.ERROR_MESSAGE);// khong du tien
							txtSotien.setText("");
							txtSotien.requestFocus();
						}
					} catch (Exception e) {
						System.out.println(e);
					}
				} else if (tiennhap == 0) {
					JOptionPane.showMessageDialog(this, loi25, loi0,
							JOptionPane.ERROR_MESSAGE);// so tien nhap phai khac
														// 0
					txtSotien.setText("");
					txtSotien.requestFocus();
				} else {
					JOptionPane.showMessageDialog(this, loi6, loi0,
							JOptionPane.ERROR_MESSAGE); // so tien nhap la boi
														// so cua 50000
					txtSotien.setText("");
					txtSotien.requestFocus();
				}
			} catch (NumberFormatException es) {
				JOptionPane.showMessageDialog(this, loi7, loi0,
						JOptionPane.ERROR_MESSAGE);// loi nhap du lieu
				txtSotien.setText("");
				txtSotien.requestFocus();
			}

		}

		else if (ae.getSource() == Huy) {
			twoPane.setBottomComponent(Pmain);
		} else if (ae.getSource() == Huy2) {
			txtSotien.setText("");
			twoPane.setBottomComponent(Pmain);
		} else if (ae.getSource() == Co) {
			LSodu.setText("");
			twoPane.setBottomComponent(Pmain);
		} else if (ae.getSource() == Khong) {
			LSodu.setText("");
			txtAccountNo.setText("");
			txtPassword.setText("");
			txtSotien.setText("");
			txtSotiennap.setText("");
			curPin.setText("");
			NewPin.setText("");
			confirmPin.setText("");
			twoPane.setBottomComponent(Plog);
		}

		// KET THUC RUT TIEN
		// <---------------------------------------------------------------------------->

		// NAP TIEN

		else if (ae.getSource() == NapTien) {
			twoPane.setBottomComponent(pnap);
			LSodu.setText("");
		} else if (ae.getSource() == napMottram) {
			try {
				int thanhcong = Nap("NapTien", nowAcc, 100000, "null");
				if (thanhcong == 1)
					twoPane.setBottomComponent(pThongbaonap);

			} catch (Exception e) {
				System.out.println(e);
			}

		} else if (ae.getSource() == napHaitram) {
			try {
				int thanhcong = Nap("NapTien", nowAcc, 200000, "null");
				if (thanhcong == 1)
					twoPane.setBottomComponent(pThongbaonap);
			} catch (Exception e) {
				System.out.println(e);
			}

		}

		else if (ae.getSource() == napNamtram) {
			try {
				int thanhcong = Nap("NapTien", nowAcc, 500000, "null");
				if (thanhcong == 1)
					twoPane.setBottomComponent(pThongbaonap);
			} catch (Exception e) {
				System.out.println(e);
			}

		}

		else if (ae.getSource() == napMottrieu) {
			try {
				int thanhcong = Nap("NapTien", nowAcc, 1000000, "null");
				if (thanhcong == 1)
					twoPane.setBottomComponent(pThongbaonap);
			} catch (Exception e) {
				System.out.println(e);
			}

		}

		else if (ae.getSource() == napSokhac) {
			twoPane.setBottomComponent(pSokhacnap);
		} else if (ae.getSource() == Nap) {
			try {
				int tiennap = Integer.valueOf(txtSotiennap.getText(), 10);
				if ((tiennap % 50000 == 0) && (tiennap != 0)) {
					try {
						int thanhcong = Nap("NapTien", nowAcc, tiennap, "null");
						if (thanhcong == 1) {
							txtSotiennap.setText("");
							twoPane.setBottomComponent(pThongbaonap);
						}
					} catch (Exception e) {
						System.out.println(e);
					}

				}

				else if (tiennap == 0) {
					JOptionPane.showMessageDialog(this, loi25, loi0,
							JOptionPane.ERROR_MESSAGE);// so tien nap phai khac
														// 0
					txtSotiennap.setText("");
					txtSotiennap.requestFocus();
				}

				else {
					JOptionPane.showMessageDialog(this, loi6, loi0,
							JOptionPane.ERROR_MESSAGE);// so tien nap la boi so
														// cua 50000
					txtSotiennap.setText("");
					txtSotiennap.requestFocus();
				}

			} catch (NumberFormatException es) {
				JOptionPane.showMessageDialog(this, loi7, loi0,
						JOptionPane.ERROR_MESSAGE);// loi nhap lieu
				txtSotiennap.setText("");
				txtSotiennap.requestFocus();
			}
		} else if (ae.getSource() == Huynap)
			twoPane.setBottomComponent(Pmain);
		else if (ae.getSource() == Huy2nap) {
			txtSotiennap.setText("");
			twoPane.setBottomComponent(Pmain);
		} else if (ae.getSource() == Conap) {
			LSodu.setText("");
			twoPane.setBottomComponent(Pmain);
		} else if (ae.getSource() == Khongnap) {
			LSodu.setText("");
			txtAccountNo.setText("");
			txtPassword.setText("");
			txtSotien.setText("");
			txtSotiennap.setText("");
			curPin.setText("");
			NewPin.setText("");
			confirmPin.setText("");
			twoPane.setBottomComponent(Plog);
		}

		// KET THUC NAP TIEN

		// <---------------------------------------------------------------------------->
		// CHUYEN KHOAN

		else if (ae.getSource() == ChuyenKhoan) {
			LSodu.setText("");
			twoPane.setBottomComponent(PChuyenkhoan);
		} else if (ae.getSource() == Thuchien) {
			try {

				int t = Integer.parseInt(Stien.getText());// so tien chuyen
				String s = Sotkhoan.getText();// so tai khoan chuyen

				boolean k = nowAcc.equals(s);
				if (k == false) {
					if (t != 0) {
						try {
							int kiemtra = Kiemtratknhan("KiemTra", s, "null",
									"null");
							if (kiemtra == 1) {
								int thanhcong = Chuyenkhoan("ChuyenKhoan",
										nowAcc, s, t);
								if (thanhcong == 1) {
									Sotkhoan.setText("");
									Stien.setText("");
									twoPane.setBottomComponent(PThongbao1);
								} else {
									JOptionPane.showMessageDialog(this, loi5,
											loi0, JOptionPane.ERROR_MESSAGE);// khong
																				// du
																				// tien
									Stien.setText("");
									Stien.requestFocus();
								}
							} else {
								JOptionPane.showMessageDialog(this, loi8, loi0,
										JOptionPane.ERROR_MESSAGE); // so tai
																	// khoan
																	// khong tim
																	// thay
																	// trong
																	// CSDL
								Sotkhoan.setText("");
								Sotkhoan.requestFocus();
							}
						} catch (Exception e) {
							System.out.println(e);
						}

					} else {
						JOptionPane.showMessageDialog(this, loi25, loi0,
								JOptionPane.ERROR_MESSAGE);// so tien nhap phai
															// khac 0
						Stien.setText("");
						Stien.requestFocus();
					}

				} else {
					JOptionPane.showMessageDialog(this, loi8, loi0,
							JOptionPane.ERROR_MESSAGE); // so tai khoan khong
														// hop le
					Sotkhoan.setText("");
					Sotkhoan.requestFocus();
				}

			} catch (NumberFormatException es) {
				JOptionPane.showMessageDialog(this, loi7, loi0,
						JOptionPane.ERROR_MESSAGE);// loi nhap lieu
				Stien.setText("");
				Stien.requestFocus();

			}

		}

		else if (ae.getSource() == Huy1) {
			Sotkhoan.setText("");
			Stien.setText("");
			twoPane.setBottomComponent(Pmain);
		}

		else if (ae.getSource() == Co1) {
			LSodu.setText("");
			twoPane.setBottomComponent(Pmain);
		} else if (ae.getSource() == Khong1) {
			LSodu.setText("");
			txtAccountNo.setText("");
			txtPassword.setText("");
			txtSotien.setText("");
			txtSotiennap.setText("");
			curPin.setText("");
			NewPin.setText("");
			confirmPin.setText("");
			twoPane.setBottomComponent(Plog);
		}

		// KET THUC PHAN CHUYEN KHOAN
		// <------------------------------------------------------------------------->

		// SO DU

		else if (ae.getSource() == SoDu) {
			try {

				Xemsodu("XemSoDu", nowAcc, "null", "null");
			} catch (Exception es) {
				System.out.println(es);
			}
		} else if (ae.getSource() == KetThuc) {
			int hoi = JOptionPane.showConfirmDialog(this, thoat, loi0,
					JOptionPane.YES_NO_OPTION);
			if (hoi == JOptionPane.YES_OPTION) {
				twoPane.setBottomComponent(Plog);
				txtAccountNo.setText("");
				txtPassword.setText("");
				LSodu.setText("");
				txtAccountNo.requestFocus();
			}

		}

		// <-------------------------------------------------------------------------------------------->

		// LUA CHON GIAO DIEN VIET-ANH

		else if (ae.getSource() == tiengviet) {
			loggin.setText("DANG NHAP");// DANG NHAP
			hd.setText("Dien so tai khoan va ma Pin sau do nhan nut NHAP");
			account.setText("Tai khoan");// tai khoan
			pin.setText("Mat khau");
			txtAccountNo.requestFocus();

			// panel doi pin

			tbdoipin.setText("DOI MAT KHAU");// DOI PIN
			pincu.setText("Mat khau cu");// pin cu
			pinmoi.setText("Mat khau moi");// pin moi
			xacnhan.setText("Xac nhan mat khau moi");// xac nhan

			// panel thong bao rut tien

			thongbao.setText("THONG BAO RUT TIEN");
			dieukien.setText("So tien rut la boi so cua 50.000");// so tien rut
																	// la boi so
																	// cua 50000
			tbruttien.setText("Nhap so tien can rut");// nhap so tien can rut
			taikhoan.setText("Tai khoan rut ");// tai khoan rut
			strut.setText("So tien rut");// so tien rut
			sdutte.setText("So du thuc te");// so du thuc te
			sduchophep.setText("So du cho phep");// so du cho phep
			Hoi.setText("Ban co muon thuc hien giao dich khac khong?");// co
																		// muon
																		// tiep
																		// tuc
																		// giao
																		// dich
																		// khong

			// panel thong bao nap tien

			thongbaonap.setText("THONG BAO NAP TIEN");
			dieukiennap.setText("So tien nap la boi so cua 50.000");// so tien
																	// nap la
																	// boi so
																	// cua 50000
			tbnaptien.setText("Nhap so tien can nap");// nhap so tien can nap
			taikhoannap.setText("Tai khoan nap ");// tai khoan nap
			stnap.setText("So tien nap");// so tien rut
			sduttenap.setText("So du thuc te");// so du thuc te
			sduchophepnap.setText("So du cho phep");// so du cho phep
			Hoinap.setText("Ban co muon thuc hien giao dich khac khong?");// co
																			// muon
																			// tiep
																			// tuc
																			// giao
																			// dich
																			// khong

			// panel thong bao chuyen khoan

			thongbao1.setText("THONG BAO CHUYEN KHOAN");
			taikhoan1.setText("Tai khoan chuyen");// tai khoan chuyen
			taikhoan2.setText("Tai khoan nhan");// tai khoan nhan
			strut1.setText("So tien da chuyen di la");// so tien chuyen
			sdutte1.setText("So du thuc te");// so du thuc te
			sduchophep1.setText("So du cho phep");// so du cho phep
			Hoi1.setText(" Ban co muon thuc hien giao dich khac khong?");// co
																			// muon
																			// tiep
																			// tuc
																			// giao
																			// dich
																			// khong

			// panel chuyen khoan

			label.setText("CHUYEN KHOAN");// chuyen khoan
			tknhan.setText("Tai khoan nhan");// tai khoan nhan
			sotien.setText("So tien");// so tien

			// cac loi va thong bao
			loi0 = "Thong bao";
			thoat = "Ban muon thoat chuong trinh khong?";
			loi1 = "Tai khoan hoac Ma pin khong hop le!!";// pass ko dung hay
															// thu lai
			loi2 = "Doi mat khau thanh cong !!!!";// doi mat khau thanh cong
			loi3 = "Sai ma xac nhan!!!!";// sai ma xac nhan
			loi4 = "Sai mat khau!!!!";
			loi5 = " Tai khoan cua ban khong du tien!!!!";// ko du tien
			loi6 = "So tien nhap phai la boi so cua 50.000 VND!!";
			loi7 = "Xin kiem tra du lieu nhap vao";// kiem tra lai du lieu nhap
													// vao
			loi8 = "Tai khoan nhan khong dung";// tai khoan nhan ko dung
			loi14 = "Trong 1 lan khong duoc rut qua 20.000.000 VND";// trong 1
																	// ngay ko
																	// duoc rut
																	// qua 20
																	// chai
			loi22 = "Mat khau khong dai qua 20 ky tu";
			loi25 = "So tien nhap phai khac 0";
			loi23 = "Mat khau khong duoc de trong";
			stconlai = "So du trong tai khoan ";// so du trong tai khoan

			// cac button cua login
			btxoa.setIcon(new ImageIcon("Data/clear.gif"));
			btxoa.setText(" Xoa  ");
			btenter.setIcon(new ImageIcon("Data/enter.gif"));
			btenter.setText(" Nhap");
			btexit.setIcon(new ImageIcon("Data/exit.gif"));
			btexit.setText("Thoat");

			// cac Button cua panel main

			RutTien.setText(" RUT TIEN ");// rut ten
			SoDu.setText("KIEM TRA SO DU");// kiem tra so du
			ChangePIN.setText("DOI MAT KHAU");
			ChuyenKhoan.setText("CHUYEN KHOAN");// chuyen khoan
			NapTien.setText("NAP TIEN");// nap tien
			KetThuc.setText("KET THUC");// ket thuc

			// cac Button cua panel rut tien so khac

			Rut.setText("Rut");// rut
			Huy2.setText("Huy");// huy

			// cac button cua panel nap tien so khac

			Nap.setText("Nap");
			Huy2nap.setText("Huy");

			// cac Button cua panel rut tien

			Huy.setText("Huy giao dich");// huy giao dich
			Sokhac.setText("So khac");// so khac

			// cac button cua panel nap tien

			Huynap.setText("Huy giao dich");
			napSokhac.setText("So khac");

			// cac Button cua panel chuyen khoan

			Thuchien.setText("Thuc hien");// thuc hien
			Huy1.setText("Huy giao dich");// huy giao dich

			// panel thong bao khi rut tien

			Co.setText("Co");// co
			Khong.setText("Khong");// ko

			// panel thong bao khi nap tien

			Conap.setText("Co");// co
			Khongnap.setText("Khong");// ko

			// panel thong bao khi chuyen khoan

			Co1.setText("Co");// co
			Khong1.setText("Khong");// ko

			// panel doi mat khau

			ChangeP.setText("Doi mat khau");
			Quaylai.setText("Quay lai");
			twoPane.setBottomComponent(Plog);
		} else if (ae.getSource() == english) {
			loggin.setText("LOGIN");
			account.setText("Account");// tai khoan
			pin.setText("Pass");
			txtAccountNo.requestFocus();
			hd.setText("Fill No Account and Code PIN then press ENTER button ");

			// panael doi pin

			tbdoipin.setText("Pass CHANGE");// DOI PIN
			pincu.setText("Current Pass ");// pin cu
			pinmoi.setText("New Pass ");// pin moi
			xacnhan.setText("Confirm Pass ");// xac nhan

			// panel thong bao rut tien

			thongbao.setText("CONGRATULATIONS");
			dieukien.setText("Money must be multiple of 50.000");// so tien rut
																	// la boi so
																	// cua 50000
			tbruttien.setText("Money needs withdrawing");// nhap so tien can rut
			taikhoan.setText("Withdrawal Accouunt  ");// tai khoan rut
			strut.setText("Withdrawal Money ");// so tien rut
			sdutte.setText("Accounts Balance");// so du thuc te
			sduchophep.setText("Permit Balance");// so du cho phep
			Hoi.setText("Do you want to continue services ?");// co muon tiep
																// tuc giao dich
																// khong

			// panel thong bao nap tien

			thongbaonap.setText("CONGRATULATIONS");
			dieukiennap.setText("Money must be multiple of 50.000");// so tien
																	// nap la
																	// boi so
																	// cua 50000
			tbnaptien.setText("Money needs recharge");// nhap so tien can nap
			taikhoannap.setText("Recharge Accouunt  ");// tai khoan nap
			stnap.setText("Recharge Money ");// so tien nap
			sduttenap.setText("Accounts Balance");// so du thuc te
			sduchophepnap.setText("Permit Balance");// so du cho phep
			Hoinap.setText("Do you want to continue services ?");// co muon tiep
																	// tuc giao
																	// dich
																	// khong

			// panel thong bao chuyen khoan

			thongbao1.setText("CONGRATULATIONS");
			taikhoan1.setText("Transfer Account ");// tai khoan chuyen
			taikhoan2.setText("Receiving Account ");// tai khoan nhan
			strut1.setText("Money of transfer ");// so tien chuyen
			sdutte1.setText("Virtual Balance");// so du thuc te
			sduchophep1.setText("Permit Balance");// so du cho phep
			Hoi1.setText("Do you want to continue services ?");// co muon tiep
																// tuc giao dich
																// khong

			// panel chuyen khoan

			label.setText("TRANSFERS");// chuyen khoan
			tknhan.setText("Receiving Account");// tai khoan nhan
			sotien.setText("Money");// so tien

			// cac loi va thong bao
			loi0 = "Notice";
			thoat = "Do you want to exit this program?";
			loi1 = "Invalid Account Or Pass, please try again !";// pass ko dung
																	// hay thu
																	// lai
			loi2 = "Change Pass successfully !!!!";// doi pin thanh cong
			loi3 = "Invalid Confirm Pass!!!!";// sai ma xac nhan
			loi4 = "Invalid Pass!!";// pass ko dung
			loi5 = "Not enough money!!!!";// ko du tien
			loi6 = "Money must be multiple of 50.000 or Not enough money!!!!";
			loi7 = "Please check the inputdata again!!!!";// kiem tra lai du
															// lieu nhap vao
			loi8 = "Invalid receiving account!!!!";// tai khoan nhan ko dung
			loi14 = "Over 20milions VND per once is not allowed";// trong 1 ngay
																	// ko duoc
																	// rut hon
																	// 20 chai
			loi22 = "Over 20 characters is not allowed";
			loi25 = "Money is not zero";
			loi23 = "Pass is not empty";
			stconlai = "Your balance is: ";// so du trong tai khoan

			// panel login
			btxoa.setIcon(new ImageIcon("Data/clear.gif"));
			btxoa.setText(" Clear  ");
			btenter.setIcon(new ImageIcon("Data/enter.gif"));
			btenter.setText("Login");
			btexit.setIcon(new ImageIcon("Data/exit.gif"));
			btexit.setText("Exit");

			// cac Button cua panel main

			RutTien.setText("  CASH WITHDRAWL  ");// rut tien
			NapTien.setText("CASH RECHARGE");// nap tien
			SoDu.setText("ACCOUNTS BALANCE");// kiem tra so du
			ChangePIN.setText("PASS CHANGE");
			ChuyenKhoan.setText("TRANSFERS");// chuyen khoan
			KetThuc.setText("EXIT");// ket thuc

			// cac Button cua panel rut tien so khac

			Rut.setText(" Ok ");// rut
			Huy2.setText("Cancel");// huy

			// cac button cua panel nap tien so khac
			Nap.setText(" Ok ");// nap
			Huy2nap.setText("Cancel");// huy

			// cac Button cua panel rut tien

			Huy.setText("Cancel");// huy giao dich
			Sokhac.setText("Other");// so khac

			// cac button cua panel nap tien

			Huynap.setText("Cancel");
			napSokhac.setText("Other");

			// cac Button cua panel chuyen khoan

			Thuchien.setText("  Ok ");// thuc hien
			Huy1.setText("Cancel");// huy giao dich

			// panel thong bao khi rut tien

			Co.setText("Yes");// co
			Khong.setText("No");// ko

			// panel thong bao sau khi nap tien
			Conap.setText("Yes");// co
			Khongnap.setText("No");// khong

			// panel thong bao khi chuyen khoan

			Co1.setText("Yes");// co
			Khong1.setText("No");// ko

			// panel doi Pass
			ChangeP.setText("Change");
			Quaylai.setText("Return");
			twoPane.setBottomComponent(Plog);
		}

		else if (ae.getSource() == disconnect) {
			int hoi = JOptionPane.showConfirmDialog(this,
					"Ban muon thoat chuong trinh khong?", "Thong bao",
					JOptionPane.YES_NO_OPTION);
			if (hoi == JOptionPane.YES_OPTION)
				System.exit(0);

		}

		// <-------------------------------------------------------------------------------------------------->

	}

	public static void main(String[] args)

	{
		JFrame f = new JFrame("Chuong trinh mo phong hoat dong cua may ATM");
		f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		twoPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, createLogoPane(),
				new Client());
		f.setContentPane(twoPane);
		f.setResizable(false);
		f.setLocation(250, 200);
		f.setSize(746, 450);
		f.show();
	}
}

